package com.ews.onlineexchange.model;

import java.math.BigDecimal;

import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.OneToOne;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;

@Entity
public class TradeRate extends DataEntity {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	private Trade	trade;	
	private BigDecimal overallScore;				//综合评分
	private String  rateText;                       //填写的评价
		
	private Integer qualityRate = 0;               		//服务质量评分
	private Integer TimeRate = 0;						//服务时限评价
	private Integer attitudeRate = 0;					//服务态度评价
	private Integer priceRate = 0;						//服务收费评价
	private Integer standardRate = 0;					//服务规范评价

	@OneToOne
	@NotNull
	@JoinColumn(unique = true)
	public Trade getTrade() {
		return trade;
	}

	public void setTrade(Trade trade) {
		this.trade = trade;
	}

	@NotNull
	@Min(value = 0L)
	public BigDecimal getOverallScore() {
		return overallScore;
	}

	public void setOverallScore(BigDecimal overallScore) {
		this.overallScore = overallScore;
	}

	@NotNull
	public String getRateText() {
		return rateText;
	}

	public void setRateText(String rateText) {
		this.rateText = rateText;
	}

	public Integer getQualityRate() {
		return qualityRate;
	}

	public void setQualityRate(Integer qualityRate) {
		this.qualityRate = qualityRate;
	}

	public Integer getTimeRate() {
		return TimeRate;
	}

	public void setTimeRate(Integer timeRate) {
		TimeRate = timeRate;
	}

	public Integer getAttitudeRate() {
		return attitudeRate;
	}

	public void setAttitudeRate(Integer attitudeRate) {
		this.attitudeRate = attitudeRate;
	}

	public Integer getPriceRate() {
		return priceRate;
	}

	public void setPriceRate(Integer priceRate) {
		this.priceRate = priceRate;
	}

	public Integer getStandardRate() {
		return standardRate;
	}

	public void setStandardRate(Integer standardRate) {
		this.standardRate = standardRate;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = super.hashCode();
		result = prime * result + ((TimeRate == null) ? 0 : TimeRate.hashCode());
		result = prime * result + ((attitudeRate == null) ? 0 : attitudeRate.hashCode());
		result = prime * result + ((overallScore == null) ? 0 : overallScore.hashCode());
		result = prime * result + ((priceRate == null) ? 0 : priceRate.hashCode());
		result = prime * result + ((qualityRate == null) ? 0 : qualityRate.hashCode());
		result = prime * result + ((rateText == null) ? 0 : rateText.hashCode());
		result = prime * result + ((standardRate == null) ? 0 : standardRate.hashCode());
//		result = prime * result + ((trade == null) ? 0 : trade.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (!super.equals(obj))
			return false;
		if (getClass() != obj.getClass())
			return false;
		TradeRate other = (TradeRate) obj;
		if (TimeRate == null) {
			if (other.TimeRate != null)
				return false;
		} else if (!TimeRate.equals(other.TimeRate))
			return false;
		if (attitudeRate == null) {
			if (other.attitudeRate != null)
				return false;
		} else if (!attitudeRate.equals(other.attitudeRate))
			return false;
		if (overallScore == null) {
			if (other.overallScore != null)
				return false;
		} else if (!overallScore.equals(other.overallScore))
			return false;
		if (priceRate == null) {
			if (other.priceRate != null)
				return false;
		} else if (!priceRate.equals(other.priceRate))
			return false;
		if (qualityRate == null) {
			if (other.qualityRate != null)
				return false;
		} else if (!qualityRate.equals(other.qualityRate))
			return false;
		if (rateText == null) {
			if (other.rateText != null)
				return false;
		} else if (!rateText.equals(other.rateText))
			return false;
		if (standardRate == null) {
			if (other.standardRate != null)
				return false;
		} else if (!standardRate.equals(other.standardRate))
			return false;
		if (trade == null) {
			if (other.trade != null)
				return false;
		} else if (!trade.equals(other.trade))
			return false;
		return true;
	}	
}
